﻿
    using Chain.BLL;
    using Chain.Common;
    using Chain.Common.DEncrypt;
    using Chain.DBUtility;
    using Chain.Model;
    using Newtonsoft.Json;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.IO;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Web;
    using System.Web.Script.Services;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using Web.Common;

    [WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1), ToolboxItem(false), ScriptService, WebService(Namespace="http://tempuri.org/")]
    public partial class ChainStockSelf : WebService
    {
        private MySelfSoapHeader _mySoapHeader;
        private MySelfSoapHeader _MySoapHeader;

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public int AddEmail(Chain.Model.EmailLog model)
        {
            if (this.MySoapHeader.CheckUser())
            {
                return new Chain.BLL.EmailLog().Add(model);
            }
            return 0;
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public void AddErrorLog(Chain.Model.SysError mdSysError)
        {
            if (this.MySoapHeader.CheckUser())
            {
                new Chain.BLL.SysError().Add(mdSysError);
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public int AddGiftExchangeDetailInfo(Chain.Model.GiftExchangeDetail model)
        {
            if (this.MySoapHeader.CheckUser())
            {
                return new Chain.BLL.GiftExchangeDetail().Add(model);
            }
            return 0;
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public int AddGiftExchangeInfo(Chain.Model.GiftExchange model)
        {
            if (this.MySoapHeader.CheckUser())
            {
                model.ExchangeStatus = 1;
                return new Chain.BLL.GiftExchange().Add(model);
            }
            return 0;
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public bool CheckFileIsExist(string path)
        {
            return (this.MySoapHeader.CheckUser() && File.Exists(base.Server.MapPath(path)));
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object CheckMemPwd(string strAccount, string strPassword)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.Model.Mem modelMem = new Chain.BLL.Mem().CheckMemPwd(strAccount.Trim(), DESEncrypt.Encrypt(strPassword.Trim()));
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(modelMem);
                    }
                    return JsonPlus.ToJson(modelMem);
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetExchangeIDByGiftNameOrGiftCode(string giftNameOrGiftCodeStrWhere)
        {
            if (!this.MySoapHeader.CheckUser())
            {
                return null;
            }
            DataTable dtExchangeID = new Chain.BLL.GiftExchange().GetExchangeIDByGiftNameOrGiftCode(giftNameOrGiftCodeStrWhere);
            if (this.MySoapHeader.SerializeRequired)
            {
                return ConvertSerialize.CompactFormatterSerialize(dtExchangeID);
            }
            return JsonPlus.ToJson(dtExchangeID, "");
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetGiftClassInfo(int classID)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.Model.GiftClass ModelClass = new Chain.BLL.GiftClass().GetModel(classID);
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(ModelClass);
                    }
                    return JsonPlus.ToJson(ModelClass);
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetGiftClassList()
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.GiftClass bllClass = new Chain.BLL.GiftClass();
                    DataTable dtClass = bllClass.GetList("").Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtClass);
                    }
                    return JsonPlus.ToJson(dtClass, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetGiftExchangeDetailByExchangeID(int exchangeID)
        {
            if (!this.MySoapHeader.CheckUser())
            {
                return null;
            }
            DataTable dtGiftExchangeDetail = new Chain.BLL.GiftExchangeDetail().GetGiftExchangeDetailByExchangeID(exchangeID);
            if (this.MySoapHeader.SerializeRequired)
            {
                return ConvertSerialize.CompactFormatterSerialize(dtGiftExchangeDetail);
            }
            return JsonPlus.ToJson(dtGiftExchangeDetail, "");
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object GetGiftExchangeListSP(int PageSize, int PageIndex, out int resCount, string strWhere)
        {
            if (this.MySoapHeader.CheckUser())
            {
                if (this.MySoapHeader.SerializeRequired)
                {
                    return ConvertSerialize.CompactFormatterSerialize(new Chain.BLL.GiftExchange().GetListGiftExchangeSP(PageSize, PageIndex, out resCount, new string[] { strWhere }).Tables[0]);
                }
                return JsonPlus.ToJson(new Chain.BLL.GiftExchange().GetListGiftExchangeSP(PageSize, PageIndex, out resCount, new string[] { strWhere }).Tables[0], "");
            }
            resCount = 1;
            return null;
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object GetGiftInfo(int giftID)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.Model.PointGift gift = new Chain.BLL.PointGift().GetModel(giftID);
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(gift);
                    }
                    return JsonPlus.ToJson(gift);
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetGiftList(int intPageSize, int intPageIndex, bool IsAsc, string strWhere, out int intResCount)
        {
            intResCount = 0;
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.PointGift bllGift = new Chain.BLL.PointGift();
                    DataTable dtGift = bllGift.GetListSP(intPageSize, intPageIndex, IsAsc, out intResCount, new string[] { strWhere }).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtGift);
                    }
                    return JsonPlus.ToJson(dtGift, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetGiftListByGids(string strWhere)
        {
            if (!this.MySoapHeader.CheckUser())
            {
                return null;
            }
            Chain.BLL.PointGift bllGift = new Chain.BLL.PointGift();
            DataTable dtGift = bllGift.GetList(strWhere).Tables[0];
            if (this.MySoapHeader.SerializeRequired)
            {
                return ConvertSerialize.CompactFormatterSerialize(dtGift);
            }
            return JsonPlus.ToJson(dtGift, "");
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public void GetGoodsList()
        {
            try
            {
                HttpContext.Current.Response.ContentType = "application/json;charset=utf-8";
                string jsonCallBackFunName = string.Empty;
                jsonCallBackFunName = HttpContext.Current.Request.Params["callback"].ToString();
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.Goods bllGoods = new Chain.BLL.Goods();
                    DataTable dtGoods = bllGoods.GetList("1=1").Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        HttpContext.Current.Response.Write(ConvertSerialize.CompactFormatterSerialize(dtGoods));
                    }
                    else
                    {
                        string json = JsonPlus.ToJson(dtGoods, "GoodsID,GoodsCode,GoodsClassID,Name,NameCode,Unit,GoodsNumber,SalePercet,GoodsSaleNumber,Price,CommissionType,CommissionNumber,Point,MinPercent,GoodsType,GoodsBidPrice,GoodsRemark,GoodsPicture,GoodsCreateTime,CreateShopID,ClassName");
                        HttpContext.Current.Response.Write(jsonCallBackFunName + "(" + json + ")");
                    }
                }
            }
            catch
            {
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetHotGifts(int top, string strwhere, string filedOrder)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.PointGift bllGift = new Chain.BLL.PointGift();
                    DataTable dtGift = bllGift.GetList(top, strwhere, filedOrder).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtGift);
                    }
                    return JsonPlus.ToJson(dtGift, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object GetLevel()
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    List<Chain.Model.MemLevel> listLevel = new Chain.BLL.MemLevel().GetLevelList("");
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(listLevel);
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.Append("[");
                    string[] strList = new string[listLevel.Count];
                    for (int i = 0; i < listLevel.Count; i++)
                    {
                        strList[i] = JsonPlus.ToJson(listLevel[i]);
                        if (i == 0)
                        {
                            sb.AppendFormat("{0}\":{1}", "{\"" + i, strList[i] + "}");
                        }
                        else
                        {
                            sb.AppendFormat(",{0}\":{1}", "{\"" + i, strList[i] + "}");
                        }
                    }
                    sb.Append("]");
                    return sb.ToString();
                }
                return null;
            }
            catch (Exception e)
            {
                Chain.BLL.SysError.Add(e, PubFunction.ipAdress);
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetMem(int memID)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.Model.Mem mem = new Chain.BLL.Mem().GetModel(memID);
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(mem);
                    }
                    return JsonPlus.ToJson(mem);
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetMemAdressBymencard(string strMemCard)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    DataTable dt = new Chain.BLL.Mem().GetMemAdressBymencard(strMemCard);
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dt);
                    }
                    return JsonPlus.ToJson(dt, "MemProvinceName,MemCityName,MemCountyName,MemVillageName,MemAddress");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public void GetMemberList()
        {
            try
            {
                HttpContext.Current.Response.ContentType = "application/json;charset=utf-8";
                string jsonCallBackFunName = string.Empty;
                jsonCallBackFunName = HttpContext.Current.Request.Params["callback"].ToString();
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.Mem bllMem = new Chain.BLL.Mem();
                    DataTable dtMem = bllMem.GetList("1=1").Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        HttpContext.Current.Response.Write(ConvertSerialize.CompactFormatterSerialize(dtMem));
                    }
                    else
                    {
                        string json = JsonPlus.ToJson(dtMem, "MemID,MemCard,MemPassword,MemName,MemSex,MemIdentityCard,MemMobile,MemPhoto,MemBirthdayType,MemBirthday,MemIsPast,MemPastTime,MemPoint,MemPointAutomatic,MemMoney,MemConsumeMoney,MemConsumeLastTime,MemConsumeCount,MemEmail,MemAddress,MemState,MemRecommendID,MemLevelID,MemShopID,MemCreateTime,MemUserID");
                        HttpContext.Current.Response.Write(jsonCallBackFunName + "(" + json + ")");
                    }
                }
            }
            catch
            {
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object GetMemCard(string strMemCard)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.Model.Mem mem = new Chain.BLL.Mem().GetModelByMemCard(strMemCard);
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(mem);
                    }
                    return JsonPlus.ToJson(mem);
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetMemCountDetailList(string strSql)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.MemCountDetail bllMemCountDetail = new Chain.BLL.MemCountDetail();
                    DataTable dtPoint = bllMemCountDetail.GetList(strSql).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtPoint);
                    }
                    return JsonPlus.ToJson(dtPoint, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object GetMemCountList(int intPageSize, int intPageIndex, string strWhere, out int intResCount)
        {
            intResCount = 0;
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.MemCount bllCount = new Chain.BLL.MemCount();
                    DataTable dtPoint = bllCount.GetListSP(intPageSize, intPageIndex, out intResCount, new string[] { strWhere }).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtPoint);
                    }
                    return JsonPlus.ToJson(dtPoint, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetMemCustomField()
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.MemCustomField bllCustom = new Chain.BLL.MemCustomField();
                    DataTable dtCustom = bllCustom.GetList("").Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtCustom);
                    }
                    return JsonPlus.ToJson(dtCustom, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetMemExpenseDetailList(string strSql)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.OrderDetail bllDetail = new Chain.BLL.OrderDetail();
                    DataTable dtOrderDetail = bllDetail.GetListSP(strSql).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtOrderDetail);
                    }
                    return JsonPlus.ToJson(dtOrderDetail, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetMemExpenseList(int intPageSize, int intPageIndex, string strWhere, out int intResCount)
        {
            intResCount = 0;
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.OrderLog bllOrderLog = new Chain.BLL.OrderLog();
                    DataTable dtExpense = bllOrderLog.GetListSP(intPageSize, intPageIndex, out intResCount, new string[] { strWhere }).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtExpense);
                    }
                    return JsonPlus.ToJson(dtExpense, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object GetMemList(string strMemCard)
        {
            if (!this.MySoapHeader.CheckUser())
            {
                return null;
            }
            Chain.BLL.Mem bllMem = new Chain.BLL.Mem();
            string strSql = string.Format(" MemCard='{0}' ", strMemCard);
            DataTable dtMem = bllMem.GetList(strSql).Tables[0];
            if (this.MySoapHeader.SerializeRequired)
            {
                return ConvertSerialize.CompactFormatterSerialize(dtMem);
            }
            return JsonPlus.ToJson(dtMem, "");
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object GetMemRecharge(string strSql)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.MemRecharge bllRecharge = new Chain.BLL.MemRecharge();
                    DataTable dt = bllRecharge.GetList(strSql).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dt);
                    }
                    return JsonPlus.ToJson(dt, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object GetMemRechargeList(int intPageSize, int intPageIndex, string strWhere, out int intResCount)
        {
            intResCount = 0;
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.MemRecharge bllRecharge = new Chain.BLL.MemRecharge();
                    DataTable dtMemRecharge = bllRecharge.GetListSP(intPageSize, intPageIndex, out intResCount, new string[] { strWhere }).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtMemRecharge);
                    }
                    return JsonPlus.ToJson(dtMemRecharge, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetMessageList(int intPageSize, int intPageIndex, string strWhere, out int intResCount)
        {
            intResCount = 0;
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.Message bllMessage = new Chain.BLL.Message();
                    DataTable dtMessage = bllMessage.GetMemMessageList(intPageSize, intPageIndex, out intResCount, new string[] { strWhere }).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtMessage);
                    }
                    return JsonPlus.ToJson(dtMessage, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public void GetModel()
        {
            try
            {
                HttpContext.Current.Response.ContentType = "application/json;charset=utf-8";
                string jsonCallBackFunName = string.Empty;
                jsonCallBackFunName = HttpContext.Current.Request.Params["callback"].ToString();
                string strWhere = string.Format(" MemCard='{0}' or MemName='{0}' or MemMobile='{0}'", HttpContext.Current.Request.Params["condition"].ToString());
                if (this.MySoapHeader.CheckUser())
                {
                    DataTable dtMem = new Chain.BLL.Mem().GetModelDetail(new string[] { strWhere });
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        HttpContext.Current.Response.Write(ConvertSerialize.CompactFormatterSerialize(dtMem));
                    }
                    else
                    {
                        string json = JsonPlus.ToJson(dtMem.Rows[0], "MemID,MemCard,MemPassword,MemName,MemSex,MemIdentityCard,MemMobile,MemPhoto,MemBirthdayType,MemBirthday,MemIsPast,MemPastTime,MemPoint,MemPointAutomatic,MemMoney,MemConsumeMoney,MemConsumeLastTime,MemConsumeCount,MemEmail,MemAddress,MemState,MemRecommendID,MemLevelID,MemShopID,MemCreateTime,MemRemark,MemUserID,MemTelePhone,MemQRCode,MemProvince,MemCity,MemCounty,MemVillage,MemQuestion,MemAnswer,MemWeiXinCard,MemCardNumber,ShopName,LevelID,LevelName,LevelPoint,LevelDiscountPercent,LevelPointPercent,LevellLock,ClassDiscountPercent,ClassPointPercent,ConsumeMoney,UserName,MemProvinceName,MemCityName,MemCountyName,MemVillageName,MemCountNumber,ClassRechargePointRate");
                        HttpContext.Current.Response.Write(jsonCallBackFunName + "(" + json + ")");
                    }
                }
            }
            catch
            {
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetPointChangeList(int intPageSize, int intPageIndex, string strWhere, out int intResCount)
        {
            intResCount = 0;
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.PointLog bllPoint = new Chain.BLL.PointLog();
                    DataTable dtPoint = bllPoint.GetListSP(intPageSize, intPageIndex, out intResCount, new string[] { strWhere }).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtPoint);
                    }
                    return JsonPlus.ToJson(dtPoint, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetPointExchangeList(int intPageSize, int intPageIndex, string strWhere, out int intResCount)
        {
            intResCount = 0;
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.PointExchange bllPointExchange = new Chain.BLL.PointExchange();
                    DataTable dtExchagne = bllPointExchange.GetListSP(intPageSize, intPageIndex, out intResCount, new string[] { strWhere }).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtExchagne);
                    }
                    return JsonPlus.ToJson(dtExchagne, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetPointLog(string strWhere)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.PointLog bllPL = new Chain.BLL.PointLog();
                    DataTable dt = bllPL.GetList(0x3e8, strWhere, "PointCreateTime desc").Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dt);
                    }
                    return JsonPlus.ToJson(dt, "PointID,PointMemID,PointNumber,PointChangeType,PointRemark,PointShopID,PointCreateTime,PointUserID,PointOrderCode,PointGiveMemID");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object GetPointRateList(int intPageSize, int intPageIndex, string strWhere, out int intResCount)
        {
            intResCount = 0;
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.PointRate bllPointRate = new Chain.BLL.PointRate();
                    DataTable dtPointRate = bllPointRate.GetMyTeamList(intPageSize, intPageIndex, out intResCount, new string[] { strWhere }).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtPointRate);
                    }
                    return JsonPlus.ToJson(dtPointRate, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object GetShopDataTable(int intPageSize, int intPageIndex, string strWhere, out int intResCount)
        {
            intResCount = 0;
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.SysShop bllShop = new Chain.BLL.SysShop();
                    DataTable dtShop = bllShop.GetListSP(intPageSize, intPageIndex, out intResCount, new string[] { (string.IsNullOrEmpty(strWhere) != null) ? "ShopID>0 and ShopState=0 " : ("ShopID>0 and ShopState=0 and " + strWhere) }).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtShop);
                    }
                    return JsonPlus.ToJson(dtShop, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetShopList()
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    List<Chain.Model.SysShop> listShop = new Chain.BLL.SysShop().GetModelList("");
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(listShop);
                    }
                    StringBuilder sb = new StringBuilder();
                    sb.Append("{");
                    string[] strShop = new string[listShop.Count];
                    for (int i = 0; i < listShop.Count; i++)
                    {
                        strShop[i] = JsonPlus.ToJson(listShop[i]);
                        if (i == 0)
                        {
                            sb.AppendFormat("{0}:[{1}]", i, strShop[i]);
                        }
                        else
                        {
                            sb.AppendFormat(",{0}:[{1}]", i, strShop[i]);
                        }
                    }
                    sb.Append("}");
                    return sb.ToString();
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public object GetSysParameter()
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.Model.SysParameter modelSysParameter = new Chain.BLL.SysParameter().GetModel(1);
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(modelSysParameter);
                    }
                    return JsonPlus.ToJson(modelSysParameter);
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object GetWebSetting()
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    StringWriter sw = new StringWriter();
                    JsonWriter writer = new JsonWriter();
                    writer.WriteStartObject();
                    writer.WritePropertyName("EnableGoods");
                    writer.WriteValue(PubFunction.curParameter.EnableGoods.ToString());
                    writer.WriteEndObject();
                    writer.Flush();
                    string jsonText = sw.GetStringBuilder().ToString();
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(jsonText);
                    }
                    return JsonPlus.ToJson(jsonText);
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [WebMethod]
        public bool GiftShare()
        {
            return PubFunction.curParameter.bolGiftShare;
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public int MemPwdReset(int intMemID, string strNewPwd)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.Mem bllMem = new Chain.BLL.Mem();
                    return bllMem.UpdateMemPwd(intMemID, DESEncrypt.Encrypt(strNewPwd.Trim()));
                }
                return 0;
            }
            catch
            {
                return 0;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public int MemRecharge(Chain.Model.MemRecharge model)
        {
            if (this.MySoapHeader.CheckUser())
            {
                return new Chain.BLL.MemRecharge().Add(model);
            }
            return 0;
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public int ModifyMemPwd(int intMemID, string strOldPwd, string strNewPwd)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.Mem bllMem = new Chain.BLL.Mem();
                    return bllMem.UpdateMemPwd(intMemID, DESEncrypt.Encrypt(strNewPwd.Trim()), DESEncrypt.Encrypt(strOldPwd.Trim()));
                }
                return 0;
            }
            catch
            {
                return 0;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public int OnlineMessage(int intMemID, string strContent)
        {
            if (this.MySoapHeader.CheckUser())
            {
                Chain.BLL.Message bllMessage = new Chain.BLL.Message();
                Chain.Model.Message modelMessage = new Chain.Model.Message();
                modelMessage.MessageMemID = intMemID;
                modelMessage.MessageContent = strContent;
                modelMessage.MessageTime = DateTime.Now;
                modelMessage.MessageIsReply = 0;
                return bllMessage.Add(modelMessage);
            }
            return 0;
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public void QuickExpense()
        {
            HttpContext.Current.Response.ContentType = "application/json;charset=utf-8";
            string jsonCallBackFunName = string.Empty;
            jsonCallBackFunName = HttpContext.Current.Request.Params["callback"].ToString();
            string memCard = HttpContext.Current.Request.Params["memcard"].ToString();
            string account = HttpContext.Current.Request.Params["account"].ToString();
            decimal money = Convert.ToDecimal(HttpContext.Current.Request.Params["money"].ToString());
            decimal discount = Convert.ToDecimal(HttpContext.Current.Request.Params["discount"].ToString());
            int point = Convert.ToInt32(HttpContext.Current.Request.Params["point"].ToString());
            string flag = "{\"tag\":\"\"}";
            Chain.BLL.Mem bllMem = new Chain.BLL.Mem();
            Chain.Model.Mem modelMem = bllMem.GetModel(memCard);
            string Remark = string.Concat(new object[] { "散客快速消费,订单号：[", account, "],消费金额：[", discount, "]" });
            if (PubFunction.IsShopPoint(modelMem.MemShopID, ref point))
            {
                try
                {
                    Chain.Model.OrderLog mdOrderLog = new Chain.Model.OrderLog();
                    new Chain.Model.SysLog();
                    Chain.Model.PointLog mdPoint = new Chain.Model.PointLog();
                    mdOrderLog.OrderMemID = modelMem.MemID;
                    mdOrderLog.OrderType = 0;
                    mdOrderLog.OrderPoint = point;
                    mdOrderLog.OrderTotalMoney = money;
                    mdOrderLog.OrderDiscountMoney = discount;
                    mdOrderLog.OrderIsCard = false;
                    mdOrderLog.OrderPayCard = 0M;
                    mdOrderLog.OrderIsCash = true;
                    mdOrderLog.OrderPayCash = discount;
                    mdOrderLog.OrderIsBink = false;
                    mdOrderLog.OrderPayBink = 0M;
                    mdOrderLog.OrderPayCoupon = 0M;
                    mdOrderLog.OrderAccount = account;
                    mdOrderLog.OrderShopID = modelMem.MemShopID;
                    mdOrderLog.OrderUserID = modelMem.MemUserID;
                    mdOrderLog.OrderRemark = Remark;
                    mdOrderLog.OrderCreateTime = DateTime.Now;
                    mdOrderLog.OrderPayType = 0;
                    mdOrderLog.OrderCardBalance = modelMem.MemMoney;
                    mdOrderLog.OrderCardPoint = modelMem.MemPoint + point;
                    Chain.BLL.OrderLog bllOrder = new Chain.BLL.OrderLog();
                    if (bllOrder.Add(mdOrderLog, account) > 0)
                    {
                        decimal dclMemMoney = modelMem.MemMoney;
                        modelMem.MemConsumeMoney += mdOrderLog.OrderDiscountMoney;
                        modelMem.MemPoint += mdOrderLog.OrderPoint;
                        modelMem.MemConsumeLastTime = DateTime.Now;
                        modelMem.MemConsumeCount++;
                        bllMem.ExpenseUpdateMem(modelMem.MemID, dclMemMoney, modelMem.MemConsumeMoney, modelMem.MemPoint, DateTime.Now, modelMem.MemConsumeCount);
                        Chain.Model.MoneyChangeLog moneyChangeLogModel = new Chain.Model.MoneyChangeLog();
                        moneyChangeLogModel.MoneyChangeMemID = modelMem.MemID;
                        moneyChangeLogModel.MoneyChangeUserID = modelMem.MemUserID;
                        moneyChangeLogModel.MoneyChangeType = 3;
                        moneyChangeLogModel.MoneyChangeAccount = account;
                        moneyChangeLogModel.MoneyChangeMoney = -discount;
                        moneyChangeLogModel.MoneyChangeCash = -discount;
                        moneyChangeLogModel.MoneyChangeBalance = 0M;
                        moneyChangeLogModel.MoneyChangeUnionPay = 0M;
                        moneyChangeLogModel.MemMoney = modelMem.MemMoney;
                        moneyChangeLogModel.MoneyChangeCreateTime = DateTime.Now;
                        moneyChangeLogModel.MoneyChangeGiveMoney = 0M;
                        new Chain.BLL.MoneyChangeLog().Add(moneyChangeLogModel);
                        mdPoint.PointMemID = modelMem.MemID;
                        mdPoint.PointNumber = point;
                        mdPoint.PointChangeType = 2;
                        mdPoint.PointRemark = string.Concat(new object[] { "会员快速消费，消费金额：[", discount, "],获得积分：", point, "]" });
                        mdPoint.PointShopID = modelMem.MemShopID;
                        mdPoint.PointCreateTime = DateTime.Now;
                        mdPoint.PointUserID = modelMem.MemUserID;
                        mdPoint.PointOrderCode = account;
                        new Chain.BLL.PointLog().Add(mdPoint);
                        if (PubFunction.curParameter.bolShopPointManage)
                        {
                            PubFunction.SetShopPoint(modelMem.MemUserID, modelMem.MemShopID, point, "会员快速消费扣除店铺积分", 2);
                        }
                        MEMPointUpdate.MEMPointRate(modelMem, mdOrderLog.OrderPoint, mdOrderLog.OrderAccount, 2, modelMem.MemUserID);
                        modelMem = new Chain.BLL.Mem().GetModel(modelMem.MemID);
                        PubFunction.UpdateMemLevel(modelMem);
                        flag = "{\"tag\":\"" + account + "\"}";
                        PubFunction.SaveSysLog(modelMem.MemUserID, 4, "会员消费", Remark, modelMem.MemShopID, DateTime.Now, PubFunction.ipAdress);
                    }
                }
                catch
                {
                    flag = "{\"tag\":\"\"}";
                }
            }
            HttpContext.Current.Response.Write(jsonCallBackFunName + "(" + flag + ")");
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public object ResetMemInfo(int intMemID)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.Mem bllMem = new Chain.BLL.Mem();
                    string strWhere = string.Format(" MemID={0} ", intMemID);
                    DataTable dtMem = bllMem.GetList(strWhere).Tables[0];
                    if (this.MySoapHeader.SerializeRequired)
                    {
                        return ConvertSerialize.CompactFormatterSerialize(dtMem);
                    }
                    return JsonPlus.ToJson(dtMem, "");
                }
                return null;
            }
            catch
            {
                return null;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public int SecuritySettings(int intMemID, string strEmail, string strQuestion, string strAnswer)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.Mem bllMem = new Chain.BLL.Mem();
                    return bllMem.SecuritySettings(intMemID, strEmail, strQuestion, strAnswer);
                }
                return 0;
            }
            catch
            {
                return 0;
            }
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public int SendMessage(int intMemID, string strReceiver, string strContent, int intUserID)
        {
            int intFlag = 0;
            try
            {
                if ((this.MySoapHeader.CheckUser() && PubFunction.curParameter.bolMoneySms) && ((int.Parse(SMSInfo.GetBalance(false).ToString()) > 0) && SMSInfo.Send_SMS(false, strReceiver, strContent, "")))
                {
                    Chain.Model.SmsLog modelSms = new Chain.Model.SmsLog();
                    modelSms.SmsMemID = intMemID;
                    modelSms.SmsMobile = strReceiver;
                    modelSms.SmsContent = strContent;
                    modelSms.SmsTime = DateTime.Now;
                    modelSms.SmsUserID = intUserID;
                    modelSms.SmsShopID = new Chain.BLL.SysUser().GetModel(intUserID).UserShopID;
                    modelSms.SmsAmount = PubFunction.GetSmsAmount(strContent);
                    modelSms.SmsAllAmount = modelSms.SmsAmount;
                    new Chain.BLL.SmsLog().Add(modelSms);
                    intFlag = 1;
                }
            }
            catch
            {
            }
            return intFlag;
        }

        [SoapHeader("MySoapHeader"), WebMethod(Description="")]
        public int SystemLog(int intUserID, int actionID, string strType, string strDetail, string strIpAddress)
        {
            if (this.MySoapHeader.CheckUser())
            {
                int intShopID = new Chain.BLL.SysUser().GetModel(intUserID).UserShopID;
                Chain.Model.SysLog modelLog = new Chain.Model.SysLog();
                modelLog.LogUserID = intUserID;
                modelLog.LogActionID = actionID;
                modelLog.LogType = strType;
                modelLog.LogDetail = strDetail;
                modelLog.LogShopID = intShopID;
                modelLog.LogCreateTime = DateTime.Now;
                modelLog.LogIPAdress = strIpAddress;
                return new Chain.BLL.SysLog().Add(modelLog);
            }
            return 0;
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public int UpdateMemInfo(int intMemID, string strMemMobile, string strMemBirthday, string strMemEmail, string strMemTelephone, string strMemIdentityCard, string strMemAddress)
        {
            try
            {
                if (this.MySoapHeader.CheckUser())
                {
                    Chain.BLL.Mem bllMem = new Chain.BLL.Mem();
                    Chain.Model.Mem modelMem = new Chain.Model.Mem();
                    modelMem = bllMem.GetModel(intMemID);
                    modelMem.MemMobile = strMemMobile.Trim();
                    modelMem.MemBirthday = DateTime.Parse(strMemBirthday);
                    modelMem.MemEmail = strMemEmail.Trim();
                    modelMem.MemAddress = strMemAddress.Trim();
                    modelMem.MemTelePhone = strMemTelephone.Trim();
                    modelMem.MemIdentityCard = strMemIdentityCard.Trim();
                    string doMain = PubConstant.DoMain;
                    return bllMem.UpdateMemSelf(modelMem);
                }
                return 0;
            }
            catch
            {
                return 0;
            }
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public int UpdateMemMoney(int memID, decimal dclMoney)
        {
            if (this.MySoapHeader.CheckUser())
            {
                return new Chain.BLL.Mem().UpdateMoney(memID, dclMoney);
            }
            return 0;
        }

        [WebMethod(Description=""), SoapHeader("MySoapHeader")]
        public int UpdateRecharge(int rechargeID)
        {
            if (this.MySoapHeader.CheckUser())
            {
                return new Chain.BLL.MemRecharge().UpdateRecharge(rechargeID);
            }
            return 0;
        }

        public MySelfSoapHeader MySoapHeader
        {
            get
            {
                if (this._MySoapHeader == null)
                {
                    return new MySelfSoapHeader();
                }
                return this._MySoapHeader;
            }
            set
            {
                this._MySoapHeader = value;
            }
        }
    }


